{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 56,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import matplotlib.pyplot as plt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>open</th>\n",
       "      <th>high</th>\n",
       "      <th>close</th>\n",
       "      <th>low</th>\n",
       "      <th>volume</th>\n",
       "      <th>price_change</th>\n",
       "      <th>p_change</th>\n",
       "      <th>turnover</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2018-02-27</th>\n",
       "      <td>23.53</td>\n",
       "      <td>25.88</td>\n",
       "      <td>24.16</td>\n",
       "      <td>23.53</td>\n",
       "      <td>95578.03</td>\n",
       "      <td>0.63</td>\n",
       "      <td>2.68</td>\n",
       "      <td>2.39</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-26</th>\n",
       "      <td>22.80</td>\n",
       "      <td>23.78</td>\n",
       "      <td>23.53</td>\n",
       "      <td>22.80</td>\n",
       "      <td>60985.11</td>\n",
       "      <td>0.69</td>\n",
       "      <td>3.02</td>\n",
       "      <td>1.53</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-23</th>\n",
       "      <td>22.88</td>\n",
       "      <td>23.37</td>\n",
       "      <td>22.82</td>\n",
       "      <td>22.71</td>\n",
       "      <td>52914.01</td>\n",
       "      <td>0.54</td>\n",
       "      <td>2.42</td>\n",
       "      <td>1.32</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-22</th>\n",
       "      <td>22.25</td>\n",
       "      <td>22.76</td>\n",
       "      <td>22.28</td>\n",
       "      <td>22.02</td>\n",
       "      <td>36105.01</td>\n",
       "      <td>0.36</td>\n",
       "      <td>1.64</td>\n",
       "      <td>0.90</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-14</th>\n",
       "      <td>21.49</td>\n",
       "      <td>21.99</td>\n",
       "      <td>21.92</td>\n",
       "      <td>21.48</td>\n",
       "      <td>23331.04</td>\n",
       "      <td>0.44</td>\n",
       "      <td>2.05</td>\n",
       "      <td>0.58</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "             open   high  close    low    volume  price_change  p_change  \\\n",
       "2018-02-27  23.53  25.88  24.16  23.53  95578.03          0.63      2.68   \n",
       "2018-02-26  22.80  23.78  23.53  22.80  60985.11          0.69      3.02   \n",
       "2018-02-23  22.88  23.37  22.82  22.71  52914.01          0.54      2.42   \n",
       "2018-02-22  22.25  22.76  22.28  22.02  36105.01          0.36      1.64   \n",
       "2018-02-14  21.49  21.99  21.92  21.48  23331.04          0.44      2.05   \n",
       "\n",
       "            turnover  \n",
       "2018-02-27      2.39  \n",
       "2018-02-26      1.53  \n",
       "2018-02-23      1.32  \n",
       "2018-02-22      0.90  \n",
       "2018-02-14      0.58  "
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data = pd.read_csv('./data/stock_day.csv')\n",
    "data = data.drop([\"ma5\",\"ma10\",\"ma20\",\"v_ma5\",\"v_ma10\",\"v_ma20\"], axis=1)\n",
    "data.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 算数运算"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 加法"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>open</th>\n",
       "      <th>high</th>\n",
       "      <th>close</th>\n",
       "      <th>low</th>\n",
       "      <th>volume</th>\n",
       "      <th>price_change</th>\n",
       "      <th>p_change</th>\n",
       "      <th>turnover</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2018-02-27</th>\n",
       "      <td>24.53</td>\n",
       "      <td>26.88</td>\n",
       "      <td>25.16</td>\n",
       "      <td>24.53</td>\n",
       "      <td>95579.03</td>\n",
       "      <td>1.63</td>\n",
       "      <td>3.68</td>\n",
       "      <td>3.39</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-26</th>\n",
       "      <td>23.80</td>\n",
       "      <td>24.78</td>\n",
       "      <td>24.53</td>\n",
       "      <td>23.80</td>\n",
       "      <td>60986.11</td>\n",
       "      <td>1.69</td>\n",
       "      <td>4.02</td>\n",
       "      <td>2.53</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-23</th>\n",
       "      <td>23.88</td>\n",
       "      <td>24.37</td>\n",
       "      <td>23.82</td>\n",
       "      <td>23.71</td>\n",
       "      <td>52915.01</td>\n",
       "      <td>1.54</td>\n",
       "      <td>3.42</td>\n",
       "      <td>2.32</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-22</th>\n",
       "      <td>23.25</td>\n",
       "      <td>23.76</td>\n",
       "      <td>23.28</td>\n",
       "      <td>23.02</td>\n",
       "      <td>36106.01</td>\n",
       "      <td>1.36</td>\n",
       "      <td>2.64</td>\n",
       "      <td>1.90</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-14</th>\n",
       "      <td>22.49</td>\n",
       "      <td>22.99</td>\n",
       "      <td>22.92</td>\n",
       "      <td>22.48</td>\n",
       "      <td>23332.04</td>\n",
       "      <td>1.44</td>\n",
       "      <td>3.05</td>\n",
       "      <td>1.58</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-06</th>\n",
       "      <td>14.17</td>\n",
       "      <td>15.48</td>\n",
       "      <td>15.28</td>\n",
       "      <td>14.13</td>\n",
       "      <td>179832.72</td>\n",
       "      <td>2.12</td>\n",
       "      <td>9.51</td>\n",
       "      <td>7.16</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-05</th>\n",
       "      <td>13.88</td>\n",
       "      <td>14.45</td>\n",
       "      <td>14.16</td>\n",
       "      <td>13.87</td>\n",
       "      <td>93181.39</td>\n",
       "      <td>1.26</td>\n",
       "      <td>3.02</td>\n",
       "      <td>4.19</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-04</th>\n",
       "      <td>13.80</td>\n",
       "      <td>13.92</td>\n",
       "      <td>13.90</td>\n",
       "      <td>13.61</td>\n",
       "      <td>67076.44</td>\n",
       "      <td>1.20</td>\n",
       "      <td>2.57</td>\n",
       "      <td>3.30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-03</th>\n",
       "      <td>13.52</td>\n",
       "      <td>14.06</td>\n",
       "      <td>13.70</td>\n",
       "      <td>13.52</td>\n",
       "      <td>139072.61</td>\n",
       "      <td>1.18</td>\n",
       "      <td>2.44</td>\n",
       "      <td>5.76</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-02</th>\n",
       "      <td>13.25</td>\n",
       "      <td>13.67</td>\n",
       "      <td>13.52</td>\n",
       "      <td>13.20</td>\n",
       "      <td>96292.73</td>\n",
       "      <td>1.32</td>\n",
       "      <td>3.62</td>\n",
       "      <td>4.30</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>643 rows × 8 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "             open   high  close    low     volume  price_change  p_change  \\\n",
       "2018-02-27  24.53  26.88  25.16  24.53   95579.03          1.63      3.68   \n",
       "2018-02-26  23.80  24.78  24.53  23.80   60986.11          1.69      4.02   \n",
       "2018-02-23  23.88  24.37  23.82  23.71   52915.01          1.54      3.42   \n",
       "2018-02-22  23.25  23.76  23.28  23.02   36106.01          1.36      2.64   \n",
       "2018-02-14  22.49  22.99  22.92  22.48   23332.04          1.44      3.05   \n",
       "...           ...    ...    ...    ...        ...           ...       ...   \n",
       "2015-03-06  14.17  15.48  15.28  14.13  179832.72          2.12      9.51   \n",
       "2015-03-05  13.88  14.45  14.16  13.87   93181.39          1.26      3.02   \n",
       "2015-03-04  13.80  13.92  13.90  13.61   67076.44          1.20      2.57   \n",
       "2015-03-03  13.52  14.06  13.70  13.52  139072.61          1.18      2.44   \n",
       "2015-03-02  13.25  13.67  13.52  13.20   96292.73          1.32      3.62   \n",
       "\n",
       "            turnover  \n",
       "2018-02-27      3.39  \n",
       "2018-02-26      2.53  \n",
       "2018-02-23      2.32  \n",
       "2018-02-22      1.90  \n",
       "2018-02-14      1.58  \n",
       "...              ...  \n",
       "2015-03-06      7.16  \n",
       "2015-03-05      4.19  \n",
       "2015-03-04      3.30  \n",
       "2015-03-03      5.76  \n",
       "2015-03-02      4.30  \n",
       "\n",
       "[643 rows x 8 columns]"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 对所有数据加一\n",
    "data.add(1)\n",
    "# 等价于data + 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2018-02-27    24.53\n",
       "2018-02-26    23.80\n",
       "2018-02-23    23.88\n",
       "2018-02-22    23.25\n",
       "2018-02-14    22.49\n",
       "Name: open, dtype: float64"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 对指定列数据加一\n",
    "data['open'].add(1).head()\n",
    "# 等价于data['open'] + 1"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 减法"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>open</th>\n",
       "      <th>high</th>\n",
       "      <th>close</th>\n",
       "      <th>low</th>\n",
       "      <th>volume</th>\n",
       "      <th>price_change</th>\n",
       "      <th>p_change</th>\n",
       "      <th>turnover</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2018-02-27</th>\n",
       "      <td>22.53</td>\n",
       "      <td>24.88</td>\n",
       "      <td>23.16</td>\n",
       "      <td>22.53</td>\n",
       "      <td>95577.03</td>\n",
       "      <td>-0.37</td>\n",
       "      <td>1.68</td>\n",
       "      <td>1.39</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-26</th>\n",
       "      <td>21.80</td>\n",
       "      <td>22.78</td>\n",
       "      <td>22.53</td>\n",
       "      <td>21.80</td>\n",
       "      <td>60984.11</td>\n",
       "      <td>-0.31</td>\n",
       "      <td>2.02</td>\n",
       "      <td>0.53</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-23</th>\n",
       "      <td>21.88</td>\n",
       "      <td>22.37</td>\n",
       "      <td>21.82</td>\n",
       "      <td>21.71</td>\n",
       "      <td>52913.01</td>\n",
       "      <td>-0.46</td>\n",
       "      <td>1.42</td>\n",
       "      <td>0.32</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-22</th>\n",
       "      <td>21.25</td>\n",
       "      <td>21.76</td>\n",
       "      <td>21.28</td>\n",
       "      <td>21.02</td>\n",
       "      <td>36104.01</td>\n",
       "      <td>-0.64</td>\n",
       "      <td>0.64</td>\n",
       "      <td>-0.10</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-14</th>\n",
       "      <td>20.49</td>\n",
       "      <td>20.99</td>\n",
       "      <td>20.92</td>\n",
       "      <td>20.48</td>\n",
       "      <td>23330.04</td>\n",
       "      <td>-0.56</td>\n",
       "      <td>1.05</td>\n",
       "      <td>-0.42</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-06</th>\n",
       "      <td>12.17</td>\n",
       "      <td>13.48</td>\n",
       "      <td>13.28</td>\n",
       "      <td>12.13</td>\n",
       "      <td>179830.72</td>\n",
       "      <td>0.12</td>\n",
       "      <td>7.51</td>\n",
       "      <td>5.16</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-05</th>\n",
       "      <td>11.88</td>\n",
       "      <td>12.45</td>\n",
       "      <td>12.16</td>\n",
       "      <td>11.87</td>\n",
       "      <td>93179.39</td>\n",
       "      <td>-0.74</td>\n",
       "      <td>1.02</td>\n",
       "      <td>2.19</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-04</th>\n",
       "      <td>11.80</td>\n",
       "      <td>11.92</td>\n",
       "      <td>11.90</td>\n",
       "      <td>11.61</td>\n",
       "      <td>67074.44</td>\n",
       "      <td>-0.80</td>\n",
       "      <td>0.57</td>\n",
       "      <td>1.30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-03</th>\n",
       "      <td>11.52</td>\n",
       "      <td>12.06</td>\n",
       "      <td>11.70</td>\n",
       "      <td>11.52</td>\n",
       "      <td>139070.61</td>\n",
       "      <td>-0.82</td>\n",
       "      <td>0.44</td>\n",
       "      <td>3.76</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-02</th>\n",
       "      <td>11.25</td>\n",
       "      <td>11.67</td>\n",
       "      <td>11.52</td>\n",
       "      <td>11.20</td>\n",
       "      <td>96290.73</td>\n",
       "      <td>-0.68</td>\n",
       "      <td>1.62</td>\n",
       "      <td>2.30</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>643 rows × 8 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "             open   high  close    low     volume  price_change  p_change  \\\n",
       "2018-02-27  22.53  24.88  23.16  22.53   95577.03         -0.37      1.68   \n",
       "2018-02-26  21.80  22.78  22.53  21.80   60984.11         -0.31      2.02   \n",
       "2018-02-23  21.88  22.37  21.82  21.71   52913.01         -0.46      1.42   \n",
       "2018-02-22  21.25  21.76  21.28  21.02   36104.01         -0.64      0.64   \n",
       "2018-02-14  20.49  20.99  20.92  20.48   23330.04         -0.56      1.05   \n",
       "...           ...    ...    ...    ...        ...           ...       ...   \n",
       "2015-03-06  12.17  13.48  13.28  12.13  179830.72          0.12      7.51   \n",
       "2015-03-05  11.88  12.45  12.16  11.87   93179.39         -0.74      1.02   \n",
       "2015-03-04  11.80  11.92  11.90  11.61   67074.44         -0.80      0.57   \n",
       "2015-03-03  11.52  12.06  11.70  11.52  139070.61         -0.82      0.44   \n",
       "2015-03-02  11.25  11.67  11.52  11.20   96290.73         -0.68      1.62   \n",
       "\n",
       "            turnover  \n",
       "2018-02-27      1.39  \n",
       "2018-02-26      0.53  \n",
       "2018-02-23      0.32  \n",
       "2018-02-22     -0.10  \n",
       "2018-02-14     -0.42  \n",
       "...              ...  \n",
       "2015-03-06      5.16  \n",
       "2015-03-05      2.19  \n",
       "2015-03-04      1.30  \n",
       "2015-03-03      3.76  \n",
       "2015-03-02      2.30  \n",
       "\n",
       "[643 rows x 8 columns]"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 所有数据减1,等价于直接减去1\n",
    "data.sub(1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2018-02-27    22.53\n",
       "2018-02-26    21.80\n",
       "2018-02-23    21.88\n",
       "2018-02-22    21.25\n",
       "2018-02-14    20.49\n",
       "              ...  \n",
       "2015-03-06    12.17\n",
       "2015-03-05    11.88\n",
       "2015-03-04    11.80\n",
       "2015-03-03    11.52\n",
       "2015-03-02    11.25\n",
       "Name: open, Length: 643, dtype: float64"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 指定哪一行减1\n",
    "data.open.sub(1)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 逻辑运算"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 逻辑运算符号: <, > , &, |"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2018-02-27    23.53\n",
       "2018-02-01    23.71\n",
       "2018-01-31    23.85\n",
       "2018-01-30    23.71\n",
       "2018-01-16    23.40\n",
       "Name: open, dtype: float64"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 逻辑运算符>和&的总和应用\n",
    "data.open[(data.open > 23) & (data.open < 24)].head()  # 中好好里边的比较运算必须加上小括号"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2018-02-27     True\n",
       "2018-02-26    False\n",
       "2018-02-23    False\n",
       "2018-02-22    False\n",
       "2018-02-14    False\n",
       "              ...  \n",
       "2015-03-06    False\n",
       "2015-03-05    False\n",
       "2015-03-04    False\n",
       "2015-03-03    False\n",
       "2015-03-02    False\n",
       "Name: open, Length: 643, dtype: bool"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.open > 23"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 逻辑函数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2018-02-27    23.53\n",
       "2018-02-01    23.71\n",
       "2018-01-31    23.85\n",
       "2018-01-30    23.71\n",
       "2018-01-16    23.40\n",
       "Name: open, dtype: float64"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# DataFrame.query('条件')\n",
    "data.query('open>23 & open<24').open.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>open</th>\n",
       "      <th>high</th>\n",
       "      <th>close</th>\n",
       "      <th>low</th>\n",
       "      <th>volume</th>\n",
       "      <th>price_change</th>\n",
       "      <th>p_change</th>\n",
       "      <th>turnover</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2018-01-05</th>\n",
       "      <td>24.0</td>\n",
       "      <td>25.40</td>\n",
       "      <td>24.51</td>\n",
       "      <td>23.70</td>\n",
       "      <td>204266.23</td>\n",
       "      <td>-0.56</td>\n",
       "      <td>-2.23</td>\n",
       "      <td>5.11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-12-18</th>\n",
       "      <td>23.0</td>\n",
       "      <td>23.49</td>\n",
       "      <td>23.13</td>\n",
       "      <td>22.83</td>\n",
       "      <td>29610.00</td>\n",
       "      <td>0.12</td>\n",
       "      <td>0.52</td>\n",
       "      <td>0.74</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-06-23</th>\n",
       "      <td>24.0</td>\n",
       "      <td>24.47</td>\n",
       "      <td>23.34</td>\n",
       "      <td>23.34</td>\n",
       "      <td>438271.69</td>\n",
       "      <td>-2.59</td>\n",
       "      <td>-9.99</td>\n",
       "      <td>10.97</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-06-21</th>\n",
       "      <td>23.0</td>\n",
       "      <td>23.84</td>\n",
       "      <td>23.57</td>\n",
       "      <td>22.90</td>\n",
       "      <td>205097.59</td>\n",
       "      <td>-0.51</td>\n",
       "      <td>-2.12</td>\n",
       "      <td>5.13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-07-24</th>\n",
       "      <td>24.0</td>\n",
       "      <td>24.55</td>\n",
       "      <td>22.99</td>\n",
       "      <td>22.38</td>\n",
       "      <td>132799.91</td>\n",
       "      <td>-1.15</td>\n",
       "      <td>-4.76</td>\n",
       "      <td>4.55</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            open   high  close    low     volume  price_change  p_change  \\\n",
       "2018-01-05  24.0  25.40  24.51  23.70  204266.23         -0.56     -2.23   \n",
       "2017-12-18  23.0  23.49  23.13  22.83   29610.00          0.12      0.52   \n",
       "2017-06-23  24.0  24.47  23.34  23.34  438271.69         -2.59     -9.99   \n",
       "2017-06-21  23.0  23.84  23.57  22.90  205097.59         -0.51     -2.12   \n",
       "2015-07-24  24.0  24.55  22.99  22.38  132799.91         -1.15     -4.76   \n",
       "\n",
       "            turnover  \n",
       "2018-01-05      5.11  \n",
       "2017-12-18      0.74  \n",
       "2017-06-23     10.97  \n",
       "2017-06-21      5.13  \n",
       "2015-07-24      4.55  "
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# DataFrame.isin(values)，满足要求的是True，不满足的是False\n",
    "data[data.open.isin([23, 24])].head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 统计计算"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## describte"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>count</th>\n",
       "      <th>mean</th>\n",
       "      <th>std</th>\n",
       "      <th>min</th>\n",
       "      <th>25%</th>\n",
       "      <th>50%</th>\n",
       "      <th>75%</th>\n",
       "      <th>max</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>open</th>\n",
       "      <td>643.0</td>\n",
       "      <td>21.272706</td>\n",
       "      <td>3.930973</td>\n",
       "      <td>12.25</td>\n",
       "      <td>19.000</td>\n",
       "      <td>21.44</td>\n",
       "      <td>23.400</td>\n",
       "      <td>34.99</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>high</th>\n",
       "      <td>643.0</td>\n",
       "      <td>21.900513</td>\n",
       "      <td>4.077578</td>\n",
       "      <td>12.67</td>\n",
       "      <td>19.500</td>\n",
       "      <td>21.97</td>\n",
       "      <td>24.065</td>\n",
       "      <td>36.35</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>close</th>\n",
       "      <td>643.0</td>\n",
       "      <td>21.336267</td>\n",
       "      <td>3.942806</td>\n",
       "      <td>12.36</td>\n",
       "      <td>19.045</td>\n",
       "      <td>21.45</td>\n",
       "      <td>23.415</td>\n",
       "      <td>35.21</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>low</th>\n",
       "      <td>643.0</td>\n",
       "      <td>20.771835</td>\n",
       "      <td>3.791968</td>\n",
       "      <td>12.20</td>\n",
       "      <td>18.525</td>\n",
       "      <td>20.98</td>\n",
       "      <td>22.850</td>\n",
       "      <td>34.01</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>volume</th>\n",
       "      <td>643.0</td>\n",
       "      <td>99905.519114</td>\n",
       "      <td>73879.119354</td>\n",
       "      <td>1158.12</td>\n",
       "      <td>48533.210</td>\n",
       "      <td>83175.93</td>\n",
       "      <td>127580.055</td>\n",
       "      <td>501915.41</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>price_change</th>\n",
       "      <td>643.0</td>\n",
       "      <td>0.018802</td>\n",
       "      <td>0.898476</td>\n",
       "      <td>-3.52</td>\n",
       "      <td>-0.390</td>\n",
       "      <td>0.05</td>\n",
       "      <td>0.455</td>\n",
       "      <td>3.03</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>p_change</th>\n",
       "      <td>643.0</td>\n",
       "      <td>0.190280</td>\n",
       "      <td>4.079698</td>\n",
       "      <td>-10.03</td>\n",
       "      <td>-1.850</td>\n",
       "      <td>0.26</td>\n",
       "      <td>2.305</td>\n",
       "      <td>10.03</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>turnover</th>\n",
       "      <td>643.0</td>\n",
       "      <td>2.936190</td>\n",
       "      <td>2.079375</td>\n",
       "      <td>0.04</td>\n",
       "      <td>1.360</td>\n",
       "      <td>2.50</td>\n",
       "      <td>3.915</td>\n",
       "      <td>12.56</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "              count          mean           std      min        25%       50%  \\\n",
       "open          643.0     21.272706      3.930973    12.25     19.000     21.44   \n",
       "high          643.0     21.900513      4.077578    12.67     19.500     21.97   \n",
       "close         643.0     21.336267      3.942806    12.36     19.045     21.45   \n",
       "low           643.0     20.771835      3.791968    12.20     18.525     20.98   \n",
       "volume        643.0  99905.519114  73879.119354  1158.12  48533.210  83175.93   \n",
       "price_change  643.0      0.018802      0.898476    -3.52     -0.390      0.05   \n",
       "p_change      643.0      0.190280      4.079698   -10.03     -1.850      0.26   \n",
       "turnover      643.0      2.936190      2.079375     0.04      1.360      2.50   \n",
       "\n",
       "                     75%        max  \n",
       "open              23.400      34.99  \n",
       "high              24.065      36.35  \n",
       "close             23.415      35.21  \n",
       "low               22.850      34.01  \n",
       "volume        127580.055  501915.41  \n",
       "price_change       0.455       3.03  \n",
       "p_change           2.305      10.03  \n",
       "turnover           3.915      12.56  "
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.describe().T"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 统计函数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "open                34.99\n",
       "high                36.35\n",
       "close               35.21\n",
       "low                 34.01\n",
       "volume          501915.41\n",
       "price_change         3.03\n",
       "p_change            10.03\n",
       "turnover            12.56\n",
       "dtype: float64"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 最大值\n",
    "data.max()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "open              12.25\n",
       "high              12.67\n",
       "close             12.36\n",
       "low               12.20\n",
       "volume          1158.12\n",
       "price_change      -3.52\n",
       "p_change         -10.03\n",
       "turnover           0.04\n",
       "dtype: float64"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 最小值\n",
    "data.min()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "open               21.272706\n",
       "high               21.900513\n",
       "close              21.336267\n",
       "low                20.771835\n",
       "volume          99905.519114\n",
       "price_change        0.018802\n",
       "p_change            0.190280\n",
       "turnover            2.936190\n",
       "dtype: float64"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 平均值\n",
    "data.mean()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "col1    3.0\n",
       "col2    3.5\n",
       "dtype: float64"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 中位数\n",
    "a = pd.DataFrame({'col1': [1, 2, 3, 3, 4, 5], 'col2': [1, 3, 2, 4, 5, 6]})\n",
    "a.median()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "open            1.545255e+01\n",
       "high            1.662665e+01\n",
       "close           1.554572e+01\n",
       "low             1.437902e+01\n",
       "volume          5.458124e+09\n",
       "price_change    8.072595e-01\n",
       "p_change        1.664394e+01\n",
       "turnover        4.323800e+00\n",
       "dtype: float64"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 方差\n",
    "data.var()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "open                3.930973\n",
       "high                4.077578\n",
       "close               3.942806\n",
       "low                 3.791968\n",
       "volume          73879.119354\n",
       "price_change        0.898476\n",
       "p_change            4.079698\n",
       "turnover            2.079375\n",
       "dtype: float64"
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 标准差\n",
    "data.std()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "open            2015-06-15\n",
       "high            2015-06-10\n",
       "close           2015-06-12\n",
       "low             2015-06-12\n",
       "volume          2017-10-26\n",
       "price_change    2015-06-09\n",
       "p_change        2015-08-28\n",
       "turnover        2017-10-26\n",
       "dtype: object"
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 求出最大值的索引\n",
    "data.idxmax()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "open            2015-03-02\n",
       "high            2015-03-02\n",
       "close           2015-09-02\n",
       "low             2015-03-02\n",
       "volume          2016-07-06\n",
       "price_change    2015-06-15\n",
       "p_change        2015-09-01\n",
       "turnover        2016-07-06\n",
       "dtype: object"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 求出最小值的索引\n",
    "data.idxmin()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 累计统计"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2015-03-02    2.62\n",
       "2015-03-03    1.44\n",
       "2015-03-04    1.57\n",
       "2015-03-05    2.02\n",
       "2015-03-06    8.51\n",
       "              ... \n",
       "2018-02-14    2.05\n",
       "2018-02-22    1.64\n",
       "2018-02-23    2.42\n",
       "2018-02-26    3.02\n",
       "2018-02-27    2.68\n",
       "Name: p_change, Length: 643, dtype: float64"
      ]
     },
     "execution_count": 49,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "new_data = data.sort_index()\n",
    "data_rise = new_data.p_change\n",
    "data_rise"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2015-03-02           2.62\n",
       "2015-03-03           9.30\n",
       "2015-03-04          21.61\n",
       "2015-03-05          41.57\n",
       "2015-03-06          77.69\n",
       "                 ...     \n",
       "2018-02-14    15048530.43\n",
       "2018-02-22    15103718.11\n",
       "2018-02-23    15159022.44\n",
       "2018-02-26    15214446.44\n",
       "2018-02-27    15269992.79\n",
       "Name: p_change, Length: 643, dtype: float64"
      ]
     },
     "execution_count": 68,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data_rise = data_rise.cumsum()\n",
    "data_rise\n",
    "# data_rise.plot()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 72,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "f:\\virtual_environment\\ai\\lib\\site-packages\\pandas\\plotting\\_matplotlib\\core.py:1235: UserWarning: FixedFormatter should only be used together with FixedLocator\n",
      "  ax.set_xticklabels(xticklabels)\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "<AxesSubplot:>"
      ]
     },
     "execution_count": 72,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXMAAAEACAYAAABBDJb9AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy86wFpkAAAACXBIWXMAAAsTAAALEwEAmpwYAAAlBElEQVR4nO3deXgV9b3H8feXfQkJQULY980AhiUgWLBApeqt2oqt0FqXilKXam8Xe2uLrVpub2u91lYLjyguiErVCtb1uhXFKmDYF9lE9iWBkIRAErJ87x8JEkOWk3CSs+Tzep48OTnnNzOfM5l8M+c3v5kxd0dERCJbo1AHEBGRM6diLiISBVTMRUSigIq5iEgUUDEXEYkCKuYiIlEgpMXczBLNbEkVr99sZotLv1ab2SP1mU9EJFJYqMaZm1k88BzQwd2HB9D+IeApd0+t83AiIhEmlHvmRcAUIBvAzFqZ2Ytm9oGZ/a1sQzPrAiSqkIuIVCxkxdzds909q8xT04H17n4+0MnMzinz2q3A7HoNKCISQcLpAOgA4HIzWwz0BroAmFkjYAKwOGTJRETCXJNQByhjM7Dc3Z8ws0uAXaXPjwOWuS4iIyJSqXDaM38UuNjMPgBuAnaXPn8h8EHIUomIRICARrOYWSLworuPq6bdLOANd38lSPlERCQA1e6Zlw4hfApoXU27cUBHFXIRkfpX7Z65mcUCBrzs7uMradMUWAe8Drzv7i9XNc/27dt7z549a5NXRKTBWrFixSF3T6jotWoPgLr7yXHgVTW7BtgI3AfcZmbd3f2hsg3MbDolww/p3r07qakaMi4iUhNmtrOy14J1AHQYMMfdDwDzKRlK+CXuPsfdU9w9JSGhwn8sIiJSS8Eq5tsoGRsOkAJU+t9DRESCr8bF3MySzGxmuafnAhNKhxXeAtwfjHAiIhKYgE8aOnnw0903AjPKvXYU+E5Qk4mISMDC6aQhERGpJRVzEZEooGIuIhIFVMxFROrJX97Zyro9WdU3rIVwumqiiEjUem/TQf78zhYKi4sZ0jUu6PPXn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j00BTVs2b+kfSL1mL3UrJf+9qSi7u99b/j26e24FWeps3bv7vRUtr+wyS9dfhfkraPci8FszWwpcBNxZi+zXABuB+4DbzKw7MLj88ql43Ve0/Kqyl32/zYC7gMspuTlLbdb7SVX+7ivJHtRtPhT5A5m2ou2mkmnrJHuwt/ky01aU5YzUSTE3s3aUfHS5Avgpgd0fdK2755c+TqXko9gPK5j3Xyqan5d8lrnVzH5HyceegKctmzcU2c2sETAB+HXpezlt2oreIyVdA+WXUWf5K1NumZXmr6DdTDMbC9wBPAU0q0X2YcAcdz9gZvOB/3b3yRUs+7R1X3757p4DBPq+fwnMcvdMM6vteg/od1/X23wFP9dL/kC3+/JZy09bl9mrmLZW23xdqosDoM2AF4A73X0ngd8f9GkzSzazxsC3gDWVtDttfmb2X2Z2TelzbYHMGkz7RV5gf31nL308DlhW+sdZoUDeYz2s+4pylV9mTdutBrpTssHXJvs2oHfp4xQqv4BbZfM7ufwHKsteiQsoKaSLgaHAulpkhwB+9xXNL1jbvLvvPIPtptb5A522iu1mHLAMaFrH2WuSqVbtgibYnfDAzZR87Ftc+nUtJcXhAeBTIK5M28VlHg8G1lLyR/HfVcw/tvz8KPl49TYlBzBnUXoyVIDTls27Bcipz+ylz/8emFzNeq30PZ7MUtfrvpJpyy9zSoDbxZTS5+8Brj6D7G0o+YP5gJJ+4y41XPf3AFcHuG0vruT5LbXJXoPffV1u84uBx+o7fw2mrWy7+T0lB1Zrtd0Euvy62Oar2pbO5KtezgC1kmFUk4AP3P1AKOdX02nDKXskLC+YInndh1P22kwbTvnDeVnhRKfzi4hEgag5A1REpCFTMRcRiQIq5iIiUUDFXEQkCqiYi4hEgf8H+ietYuxsUiQAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# plt.figure(figsize=(20, 8), dpi=100)\n",
    "data_rise.plot()\n",
    "# plt.set_xticklabels(color='w', fontsize=15)\n",
    "# plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 自定义运算"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 66,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "open     22.74\n",
       "close    22.85\n",
       "dtype: float64"
      ]
     },
     "execution_count": 66,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# apply(func, axis=0)\n",
    "data[['open', 'close']].apply(lambda x: x.max()-x.min(), axis=0)\n",
    "# data.open.max() - data.open.min()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.7"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
